<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>角色管理</title>
    <c:import url="/layout/_imports.jsp"></c:import>
</head>
<body>
<c:import url="/layout/_nav.jsp"></c:import>
<div class="container">
    <h2>角色设置</h2>

    <form action="/user/role/${id}" method="post">
        <input type="hidden" name="page" value="${page}">
        <input type="hidden" name="size" value="${size}">

        <div class="form-group row">
            <label class="col-sm-2" for="UserName">用户名</label>
            <div class="col-sm-10">
                <input class="form-control" id="UserName" type="text" value="${u.username}" readonly>
            </div>
        </div>

        <div class="form-group row">
            <label class="col-sm-2">角色</label>
            <div class="col-sm-10">
                <select class="form-control" name="role">
                    <c:forEach varStatus="type" items="${roles}" var="r">
                        <option value="${r.id}"
                                <c:if test="${(u.roleId == null && r.id=='default') || r.id == u.roleId}">selected</c:if>>${r.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>

        <button type="submit" class="btn btn-primary">保存</button>
        <a href="/user/manage?page=${page}&size=${size}" class="btn btn-secondary">返回列表</a>
    </form>
</div>
</body>
</html>
